package com.briup.cms.util;

import com.briup.cms.exception.CmsException;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ExceptionHandler {

    @org.springframework.web.bind.annotation.ExceptionHandler(Exception.class)
    public Result handleException(Exception ex){
        CmsException cmsException = null;
        if(ex instanceof CmsException){
            cmsException = (CmsException) ex;
        }else {
            cmsException = new CmsException(StatusCode.SYSTEM_INNER_ERROR);
        }
        return Result.fail(cmsException.getStatusCode());
    }

}
